import data.Dictionary
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import java.io.File

fun main() {
//    val p = Pattern.compile("<p>(.*)</p><span class=\"copyBtn\" data-desc=\"(.*)\"")
    //<p>(。・∀・)ノ</p><span class="copyBtn" data-desc="同意"
    val list = File("converter/data/lmeee_dict_data.txt").readLines().map {str->
        val arr = str.split("</p><span class=\"copyBtn\" data-desc=\"")

        val paste = arr[0].split("<p>")[1]
        val name = arr[1].split("\"")[0]
        Dictionary(
            name = name,
            keyWord = name+paste,
            paste = paste
        )
    }
    File("converter/out/lmeee_dict_data.json").apply {
        delete()
        parentFile.mkdirs()
        createNewFile()
    }.writeText(Json.encodeToString(list))
}